\newtheorem{definition}{Definition}
\newcounter{example}[chapter]

\newenvironment{example} %
{\refstepcounter{example} \textit{Example \thechapter.\theexample.}}
{\hfill \ensuremath{\blacksquare}}

\newcounter{question}

\newenvironment{question}[1] %
{\refstepcounter{question} \textit{Question \thequestion. #1}}
{\hfill \ensuremath{\blacksquare}}

\def\textbox#1{ %
  \begin{center}
  \noindent\fbox{
  \begin{minipage}[b]{0.95\columnwidth}
  #1
  \end{minipage}}
  \end{center}
}

\newenvironment{source} %%
{\footnotesize
\setlength{\parskip}{0pt}
\renewcommand{\baselinestretch}{1}
\begin{alltt}}
{\end{alltt}\normalsize}

\renewcommand{\algorithmiccomment}[1]{\small\{#1\}\normalsize}

\algnewcommand\textkeyword{\textbf}%
\algnewcommand\keyword{\textbf}%
\algnewcommand\var{\ensuremath}%

\algdef{SE}{Begin}{End}{\textkeyword{begin}}{\textkeyword{end}}%
\algdef{S}[FOR]{ForEach}[1]{\textkeyword{for each}\ #1\ \textkeyword{do}}%
\algdef{SE}[Output]{Output}{EndOutput}{\textkeyword{Output}}{}%
\algdef{SE}[Var]{Var}{EndVar}{\textkeyword{var}}{}%
\algdef{SE}[Inteface]{Interface}{EndInterface}{\textkeyword{interface}\ }{\textkeyword{end}}

\def\true{\textkeyword{true}}
\def\false{\textkeyword{false}}
\def\function{\textkeyword{function}}
\def\procedure{\textkeyword{procedure}}
\def\interface{\textkeyword{interface}}

\newenvironment{algo} %
{
\noindent
\begin{minipage}[tb]{0.95\columnwidth}
\begin{algorithmic}[1]
}
%%% end commands
{
\end{algorithmic}
\end{minipage}
}

\newif\ifremarks
\remarkstrue %makes REMARKs visible
%\remarksfalse %makes REMARKs invisible
\long\outer\def\REMARK#1#2{        % 1 = reviewer (1, 2, ...); 2 = comment
  \ifremarks
  \begin{center}
  \marginpar{\raggedright \textbf{#1}}\noindent\fbox{
  \begin{minipage}[b]{0.95\columnwidth}
  #2
  \end{minipage}}
  \end{center}
  \fi
}


\def\mono#1{\texttt{#1}}
\def\entityname#1{\texttt{#1}}
\def\Seq#1{\ensuremath{\left\langle #1 \right\rangle}}
\def\Set#1{\ensuremath{\left\{ #1 \right\}}}

\def\Prop{\ensuremath{{\cal P}}}

\def\Actors{\ensuremath{A}}
\def\Goals{\ensuremath{G}}
\def\Decompose{\ensuremath{Dc}}
\def\Dependency{\ensuremath{Dp}}
\def\Capabilities{\ensuremath{Cap}}
\def\Actions{\ensuremath{Act}}
\def\Solution{\ensuremath{S}}
\def\PropDescriptor{\ensuremath{\mathcal{P}^d}}
\def\PropValue{\ensuremath{\mathcal{P}^v}}
\def\Evaluator{\ensuremath{EV}}
\def\evaluator{\ensuremath{ev}}
\def\Event{\ensuremath{E}}
\def\event{\ensuremath{e}}


\def\actor{\ensuremath{a}}
\def\role{\ensuremath{r}}
\def\agent{\ensuremath{ag}}
\def\goal{\ensuremath{g}}
\def\desire{\ensuremath{d}}
\def\decompose{\ensuremath{dc}}
\def\dependency{\ensuremath{dp}}
\def\action{\ensuremath{act}}

\def\satcost#1{\ensuremath{\mathbf{cs}_{#1}}}
\def\decomposecost#1{\ensuremath{\mathbf{cr}_{#1}}}
\def\delegatecost#1{\ensuremath{\mathbf{cd}_{#1}}}

\def\satbenefit#1{\ensuremath{\mathbf{bs}_{#1}}}
\def\decomposebenefit#1{\ensuremath{\mathbf{br}_{#1}}}
\def\delegatebenefit#1{\ensuremath{\mathbf{bd}_{#1}}}

\def\normfunc{\ensuremath{\mathbf{norm}}}

\def\goaldiraff{\ensuremath{G_{dir\_aff}(a, S)}}
\def\goalaff{\ensuremath{G_{aff}(a, S)}}
\def\goalref{\ensuremath{G_r}}
\def\goalweight{\ensuremath{w(g)}}

